package org.monkey.request.plugin.entity;


import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import java.util.Date;
import java.util.Map;
import lombok.Data;

@Data
public class RequestInfo {

  private Date startTime;
  private String request;
  private Map<String, String> headers;
  private String response;
  private Map<String, String> customData;
  private Date endTime;
  private String ip;
  private String url;
  private String httpMethod;
  private String methodName;
  private String beforeDescription;
  private String afterDescription;
  private String tags;

  public String hearToStringLimit(int i){
    String s = JSONUtil.toJsonStr(headers);
    if(StrUtil.isNotBlank(s)&&i<s.length()){
      s = s.substring(0,i);
    }
    return s;
  }

  public String customDataToStringLimit(int i){
    String s = JSONUtil.toJsonStr(customData);
    if(StrUtil.isNotBlank(s)&&i<s.length()){
      s = s.substring(0,i);
    }
    return s;
  }
}
